<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_peimilk/model')->方法名();
*/
namespace jy_peimilk;
defined('BY_JYA') or exit('error');
class sendlog extends \plugin{
	public function stopday($day='',$merchid=0){
		$daytime=strtotime($day);
		if($daytime<time()){
			exi('只能停送最晚明天的配送单！','error');
		}
		if(!$merchid){
			exi('请选择商户！','error');
		}
		$sendlogs=$this->getall('sendlog',array('day'=>$day,'status'=>array(0,1),'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'is_dingpei'=>1),'buymid');
		if($sendlogs){
			foreach($sendlogs as $g){
				$this->model('order')->upallgoodssendlog($g['buymid'],$merchid);
				//$lastlog=$this->get('sendlog',array('buymid'=>$g['buymid'],'day'=>$day,'status'=>array(0,1),'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'is_dingpei'=>1),'','daytime desc');
				//$daygoods=json_decode($lastlog['goods'],true);
			}
		}
		return false;
	}
	public function delstopday($day='',$merchid=0){
		$daytime=strtotime($day);
		if(!$merchid){
			exi('请选择商户！','error');
		}
		if($daytime<time()){
			return false;
		}
		$goodsset=$this->getall('goodsset',array('lastnum >'=>0,'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),'mid');
		if($goodsset){
			foreach($goodsset as $g){
				$this->model('order')->upallgoodssendlog($g['mid'],$merchid);
				//$lastlog=$this->get('sendlog',array('buymid'=>$g['buymid'],'day'=>$day,'status'=>array(0,1),'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'is_dingpei'=>1),'','daytime desc');
				//$daygoods=json_decode($lastlog['goods'],true);
			}
		}
		return false;
	}
}
?>